{% extends "template.html" %}
{% load blog_extras %}

{% block title %}
	没有比人更高的山——日志
{% endblock %}

{% block sidebar %}
	<h1>日志分类</h1>
	<div class="left-box">
		<ul class="sidemenu">
			{% for catagory in catagories %}				
			<li><a href="/blog/catagory/{{catagory.id}}/">{{catagory.name}}({{catagory.diarys.all|length}})</a></li>
			{% endfor %}
		</ul>	
	</div>
	
	<h1>日志标签</h1>
	<div class="left-box">
		<ul class="sidemenu">
			{% for tag in tags %}
			<li><a href="/blog/tag/{{tag.id}}/">{{tag.name}}({{tag.diarys.all|length}})</a></li>
			{% endfor %}
		</ul>
	</div>
	
	<h1>日志评论</h1>
	<div class="left-box">
		{% for comment in comments %}
		<p>{{comment.content}}</p>
		{% endfor %}
	</div>
{% endblock %}

{% block main %}
	{% if diarys.object_list|length_is:"0" %}
		<h3>暂时还没有日志，谢谢关注！</h3>
	{% else %}
		{% for diary in diarys.object_list %}
		<a href="/blog/diary/{{diary.id}}/"><h1>{{diary.title}}</h1></a>
		<p>{% autoescape off %}{{diary.content|truncatehanzi:"120"}}</div>{% endautoescape %}</p>
		<div class="post-footer align-left">
			<div style="float:left;">
			标签：
			{% for tag in diary.tags.all %}
				<a href="/blog/tag/{{tag.id}}">{{tag.name}} </a> {% if not forloop.last %} | {% endif %}
			{% endfor %}
			</div>
			<div style="float:right;">
				<a href="/blog/diary/{{diary.id}}/" class="readmore">阅读全文</a>
				<a href="/blog/diary/{{diary.id}}/#comment" class="comments">评论 ({{diary.comments.all|length}})</a>
				<span class="read_count">点击次数：{{diary.read_count}}</span>
				<span class="date">{{diary.post_time|date:"Y-m-d H:i"}}</span>
			</div>
			<div style="clear:both;"></div>
		</div>
		<div style="clear:both;"></div>
		{% endfor%}
		<div class="pagination">
		    <span class="step-links">
		    	共{{diarys.paginator.num_pages}}页 | 
		    	{% ifnotequal diarys.number 1 %}<a href="/blog/catagory/{{catagory_id}}/1/">第一页</a>{% endifnotequal %}
		    	{% ifequal diarys.number 1 %}第一页{% endifequal %}
		    	
		    	{% if diarys.has_previous %}<a href="/blog/catagory/{{catagory_id}}/{{ diarys.previous_page_number }}/">上一页 </a>{% endif %}
		    	{% if not diarys.has_previous %}上一页 {% endif %}
		    	
		    	{% for index in diarys.paginator.page_range%}
		    		{% ifequal diarys.number index%}
		    			[{{index}}]
		    		{% endifequal%}
		    		{% ifnotequal diarys.number index%}
		    			<a href="/blog/catagory/{{catagory_id}}/{{ index }}/">[{{index}}]</a>
		    		{% endifnotequal%}
		    	{% endfor %}
		    	
		    	{% if diarys.has_next %}<a href="/blog/catagory/{{catagory_id}}/{{ diarys.next_page_number }}/">下一页 </a>{% endif %}
		    	{% if not diarys.has_next %}下一页 {% endif %}
		    	
		    	{% ifnotequal diarys.number diarys.paginator.num_pages %}<a href="/blog/catagory/{{catagory_id}}/{{diarys.paginator.num_pages}}/">最末页</a>{% endifnotequal %}
		    	{% ifequal diarys.number diarys.paginator.num_pages %}最末页{% endifequal %}
		    </span>
		</div>
	{% endif %}
{% endblock %}